package com.opengroupe.recognize;

import android.hardware.Camera.CameraInfo;
import android.hardware.Camera;
import android.util.Log;


public class Utility {
	
	private static String LOG_TAG = "Utility";
	
	public static int findFrontFacingCamera() {
		int cameraId = -1;
		int numberOfCameras = Camera.getNumberOfCameras();
		for (int i = 0; i < numberOfCameras; i++) {
			CameraInfo info = new CameraInfo();
			Camera.getCameraInfo(i, info);
			if (info.facing == CameraInfo.CAMERA_FACING_FRONT) {
				Log.d(LOG_TAG, "Camera trouver.");
				cameraId = i;
				break;
			}
		}
		return cameraId;
	}

	public static int findBackFacingCamera() {
		int cameraId = -1;
		int numberOfCameras = Camera.getNumberOfCameras();
		for (int i = 0; i < numberOfCameras; i++) {
			CameraInfo info = new CameraInfo();
			Camera.getCameraInfo(i, info);
			if (info.facing == CameraInfo.CAMERA_FACING_BACK) {
				Log.d(LOG_TAG, "Camera trouver.");
				cameraId = i;
				break;
			}
		}
		return cameraId;
	}
}
